﻿Imports ICtagControl.TenKey

Module modTenkey

    Public Delegate Sub TenkeyEvent()
    Private tkEvent As TenkeyEvent
    Private tklInput As TenKeyLabel

    Public Sub CallTenkey(ByRef lblInput As TenKeyLabel, ByVal frm As Form, ByVal tenkeyEvent As TenKey.InputCompletedEventHandler, _
                          Optional ByVal iLeft As Integer = 0, Optional ByVal iTop As Integer = 0)
        'Me.Focus()
        Dim tk As New TenKey(lblInput)
        'Dim pos As New Point(iLeft, iTop)
        'iDifTop = lblInput.Parent.Top
        tk.Top = iTop + lblInput.Height / 2
        tk.Left = iLeft
        If tk.Right > frm.Width Then
            tk.Left = frm.Width - tk.Width - 50
        End If

        '蘇州対応　2017/04/26 maruyama@tmc
        'フレームの幅をはみ出さないよう修正
        If tk.Bottom > frm.Height - SystemInformation.CaptionHeight - (SystemInformation.FrameBorderSize.Height * 2) Then
            tk.Top = iTop - tk.Height - lblInput.Height
        End If

        AddHandler tk.InputCompleted, tenkeyEvent

        'tk.Location = pos
        frm.Controls.Add(tk)
    End Sub

    Private Sub Tenkey_Done(ByVal sender As Object)
        tklInput.EndEdit()
        tkEvent()
    End Sub
End Module
